package Day011_多线程1.ZuoYe;

/**
 * @author zhangyan
 * @date 2020/4/28 16:57
 */
public class Test4 {
    public static void main(String[] args) {

        MyThread2 mt2 = new MyThread2("线程A");
        MyThread3 mt3 = new MyThread3("线程B");
        mt2.start();
        mt3.start();
    }
}

class MyThread2 extends Thread{
    public MyThread2() {
    }

    public MyThread2(String name) {
        super(name);
    }

    @Override
    public void run() {
        int sum1 = 0;
        for (int i = 1; i <= 100; i++) {
            sum1 += i;
        }
        System.out.println("线程A计算1--100的累加和，结果：" + sum1);
    }
}

class MyThread3 extends Thread{
    public MyThread3() {
    }

    public MyThread3(String name) {
        super(name);
    }

    @Override
    public void run() {
        int sum2 = 0;
        for (int i = 1; i <= 1000; i++) {
            sum2 += i;
        }
        System.out.println("线程B计算1--1000的累加和，结果：" + sum2);
    }
}